package com.aaa.controller;

import com.aaa.dto.AddressDto;
import com.aaa.dto.UserMinInfo;
import com.aaa.pojo.DefaultMsg;
import com.aaa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    @ResponseBody
    public DefaultMsg login(String username, String password) {
        return userService.login(username, password);
    }

    @RequestMapping("/register")
    @ResponseBody
    public DefaultMsg register(String username, String password) {
        return userService.register(username, password);
    }

    @RequestMapping("/findUser")
    @ResponseBody
    public DefaultMsg findUser(String username) {
        return userService.findUser(username);
    }

    @RequestMapping("/findAddressByUserId")
    @ResponseBody
    public List<AddressDto> findAddressByUserId(Integer userId) {
        return userService.findAddressByUserId(userId);
    }
    @RequestMapping("/updateMinUserInfo")
    @ResponseBody
    public DefaultMsg updateMinUserInfo(UserMinInfo userMinInfo) {
        return userService.updateMinUserInfo(userMinInfo);
    }


}
